Skip to content

perf(textbox): add input draining for typing responsiveness#30

Closed
mathiasbourgoin wants to merge 1 commit intomainfrom
perf/textbox-typing-responsiveness
Closed

perf(textbox): add input draining for typing responsiveness#30
mathiasbourgoin wants to merge 1 commit intomainfrom
perf/textbox-typing-responsiveness

Conversation

@mathiasbourgoin
Copy link
Collaborator

Summary

Add Input_drain capability so textbox widgets can process all buffered printable
characters at once, preventing lag when typing fast.

Problem

When typing quickly in a textbox, characters could buffer up in the terminal input and
each keystroke triggered a full render cycle. This caused noticeable lag between
typing and seeing characters appear.

Solution

  • Add Miaou_helpers.Input_drain module with drain_pending_chars() function
  • Driver registers a drain function at startup that reads buffered printable chars
  • Textbox_widget.handle_key drains and applies pending chars after each keystroke

Changes

  • src/miaou_helpers/input_drain.ml / .mli: New capability module
  • src/miaou_driver_term/lambda_term_driver.ml: Register drain function
  • src/miaou_widgets_input/textbox_widget.ml: Use drain in handle_key

Test plan

  • dune build passes
  • dune runtest passes
  • Fast typing in textbox feels responsive

Add Input_drain capability so textbox widgets can process all buffered
printable characters at once, preventing lag when typing fast.

- Add Miaou_helpers.Input_drain module with drain_pending_chars()
- Driver registers drain function at startup
- Textbox_widget.handle_key drains pending chars after each keystroke
- Validated_textbox uses the same mechanism

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mathiasbourgoin
Copy link
Collaborator Author

Closing as obsolete. The Matrix driver (now default) solves typing lag at the architectural level with non-blocking 1ms polling at 30 TPS, which comfortably keeps up with human typing speed. The matrix driver also has its own drain mechanisms at the driver level (drain_nav_keys, drain_esc_keys in input_parser.ml). Additionally, the PR is 119 commits behind main and doesn't work with the new on_key / Key_event.result API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments